<?php

/**
 * IndexController - The default controller class
 *
 * @author
 * @version
 */

require_once 'Zend/Controller/Action.php';

class CategoryLogoController extends App_Zend_Controller_Action_Shop
{
    public function detailAction()
    {
    	$this->view->styleName = 'product-list';
        $id = $this->_request->getParam('cid');
		$idArray[0] = intval($id);
		$idArray[1] = 'ok';
        if($idArray[1] == '') {
            $this->_forward('index','error');
        } else {   
            $cid = $idArray[0];
            $item = new CItem();            
            $this->getHelper('Fenlei')->getCategories();
			
            $productFl = new CFenlei('product');
            $productFl->order = "en_flname ASC";
            $flArray = $this->getHelper('Fenlei')->getFenleiChild($productFl->getFenleiTree(),$cid);

			if ($cid == 93) {
            	$this->view->isNational = 1;
            }

            $flArray2 = $productFl->getFenleiByPid($cid);
            $flArray1=array();
            if ($productFl->getFenleiByPid($flArray2[0]["flid"])) {
                $flArray1 = $flArray2;
                $this->view->assign('flArray1',$flArray1);
                $flArray2 = $productFl->getFenleiByPid($flArray2[0]["flid"]);
            } else {
                $flArray1="";
            }
            $this->view->assign('flArray1',$flArray1);
            $this->view->assign('flArray2',$flArray2);
           
            $parentArray=$this->getHelper('Fenlei')->getAllParents($this->view,$cid);
            $navFlString=join(' &gt;&gt; ',$parentArray);
            $this->view->assign ( "parentArray", $parentArray );
            $this->view->assign ( "navFlString", $this->view->toText($navFlString) );           
            //$this->view->webSiteDescription = 'Category: '.$this->view->toText($navFlString);
            $fenlei = new CFenlei('product');
            $current = $fenlei->find($id)->current();
            if (!empty($current->title)) {
            	$this->view->webSiteDescription = 'Buy cheap club football jerseys in newjerseysoccer.net, shop for cheap custom team football jersey shirt. All the best team football uniforms in wholesale price.';
                $this->view->webSiteTitle =  'Buy '.$current->title . ',cheap football jersey Wholesale,Free Shipping';
	            $this->view->webSiteKeywords = $current->keywords;
            } else {
            	$this->view->webSiteTitle = 'Buy '.$this->view->toText($parentArray[count($parentArray)-1]).',cheap football jersey Wholesale';
            	$this->view->webSiteKeywords = $this->view->toText($parentArray[count($parentArray)-1]);
            	$this->view->webSiteDescription = 'Buy cheap club football jerseys in newjerseysoccer.net, shop for cheap custom team football jersey shirt. All the best team football uniforms in wholesale price.';
            }
            
            //SET META FOR FACEBOOK
	        $this->getHelper ('layout')->getView()->headMeta()->setName('og:title', $this->view->toText($parentArray[count($parentArray)-1]));
			$this->getHelper ('layout')->getView()->headMeta()->setName('og:type', 'jersery');
			$this->getHelper ('layout')->getView()->headMeta()->setName('og:url', MY_URL);
			$this->getHelper ('layout')->getView()->headMeta()->setName('og:image', MY_URL.'/images/logo.jpg');
			$this->getHelper ('layout')->getView()->headMeta()->setName('og:site_name', 'newjerseysoccer.net');
			$this->getHelper ('layout')->getView()->headMeta()->setName('og:description', $this->view->toText($parentArray[count($parentArray)-1]));
        }

    }


    public function newproductAction()
    {

        $page=$this->_request->getParam('page',1);

        $order=$this->_request->getParam('order',0);


        $item=new CItem();

        $isNewItemArray=$item->getAllItems(0,8,'product',0,0,"has_banned","type='2'",'view_num DESC');

        $this->view->assign('isNewItemArray',$isNewItemArray);

        $this->getHelper('Fenlei')->getCategories();


        $itemShow=new CItemShow();

        $itemShow->setType('product');

        //$itemShow->setWhere($where);

        $itemCounts=$itemShow->getAllItemCounts();

        Zend_Loader::loadClass("CFilter");

        $pageArray = CFilter::filterPage ( $page, $itemCounts, 12 );

        $itemShow->setFromTo(array('counts'=>12,'from'=>$pageArray['from']));

        $myorder='';

        if($order=='0')
        {

            $myorder=R_PRE."items.add_time DESC";

        }elseif($order=='1')
        {

            $myorder=R_PRE."products.min_price DESC";

        }elseif($order=='2')
        {

            $myorder=R_PRE."products.min_price ASC";

        }

        $itemShow->setOrder($myorder);

        $itemArray=$itemShow->getAllItems();

        Zend_Loader::loadClass("CPage");

        $pageString = CPage::divPages( $pageArray ['pageNumber'], $pageArray ['page'], MY_URL."/category-newproduct/?order=$order");

        $this->view->assign ( "pageString", $pageString );

        $this->view->assign ( "pageArray", $pageArray );

        $this->view->assign('itemArray',$itemArray);

        $this->view->assign('itemCounts',$itemCounts);

        $this->view->assign('order',$order);

        $this->view->assign('page',$page);

        $bulletinArray=$item->getAllItems(0,12,'bulletin');

        $this->view->assign('bulletinArray',$bulletinArray);

        $this->view->assign ( "website_description", 'New jerseys' );

        $this->view->assign ( "website_title", 'New jerseys');

        $this->render('items');

    }


    public function hotproductAction()
    {

        $page=$this->_request->getParam('page',1);

        $order=$this->_request->getParam('order',0);


        $item=new CItem();

        $isNewItemArray=$item->getAllItems(0,8,'product',0,0,"has_banned","type='2'",'view_num DESC');

        $this->view->assign('isNewItemArray',$isNewItemArray);

        $this->getHelper('Fenlei')->getCategories();


        $itemShow=new CItemShow();

        $itemShow->setType('product');

        $where="type='1'";

        $itemShow->setWhere($where);

        $itemCounts=$itemShow->getAllItemCounts();

        Zend_Loader::loadClass("CFilter");

        $pageArray = CFilter::filterPage ( $page, $itemCounts, 12 );

        $itemShow->setFromTo(array('counts'=>12,'from'=>$pageArray['from']));

        $myorder='';

        if($order=='0')
        {

            $myorder=R_PRE."items.add_time DESC";

        }elseif($order=='1')
        {

            $myorder=R_PRE."products.min_price DESC";

        }elseif($order=='2')
        {

            $myorder=R_PRE."products.min_price ASC";

        }

        $itemShow->setOrder($myorder);

        $itemArray=$itemShow->getAllItems();

        Zend_Loader::loadClass("CPage");

        $pageString = CPage::divPages( $pageArray ['pageNumber'], $pageArray ['page'], MY_URL."/category-hotproduct/?order=$order");

        $this->view->assign ( "pageString", $pageString );

        $this->view->assign ( "pageArray", $pageArray );

        $this->view->assign('itemArray',$itemArray);

        $this->view->assign('itemCounts',$itemCounts);

        $this->view->assign('order',$order);

        $this->view->assign('page',$page);

        $bulletinArray=$item->getAllItems(0,12,'bulletin');

        $this->view->assign('bulletinArray',$bulletinArray);

        $this->view->assign ( "website_description", 'Hot jerseys' );

        $this->view->assign ( "website_title", 'Hot jerseys');

        $this->render('items');

    }


    public function postAction()
    {

    //$this->_helper->viewRenderer->setNoRender();

    //$this->getHelper ('layout')->disableLayout ();

    }



}
